package com.base.leetcode;

import com.base.dataStructure.queue.ArrayQueue1;
import com.sun.jmx.remote.internal.ArrayQueue;

import java.io.PipedReader;

/**
 * @Author: hdhao
 * @Create: 2023/4/1 - 22:36
 * @Version: v1.0
 */
//使用单队列模拟栈
public class Leetcode225 {
    /*
    栈顶      栈底

    队列头     队列尾
     */
    ArrayQueue1<Integer> queue = new ArrayQueue1<>(100);
    private int size = 0;

    public void push(int x){
        queue.offer(x);

        for (int i = 0;i<size;i++){
            queue.offer(queue.poll());
        }
        size++;
    }
    public int pop(){
        size--;
        return queue.poll();
    }
    public int top(){
        return queue.peek();
    }
    public boolean empty(){
        return queue.isEmpty();
    }
}
